<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Bankserver login page</title>
		<script type="text/javascript">
			function setControlType(typeName) {
				document.forms[0].control_type.value = typeName;
				return true;
			}			
			function setId(id){
				document.forms[1].id_type.value = id;
				return true;
			}
		</script>				
	</head>
	
	<body>
		
		
		
			<h3>List of departments</h3>
		
		<c:choose>
			<c:when test="${enter == true}">
				<form method="post" action="choosedepartment.do">	
					
						
							<c:forEach items="${departmentList}" var="dept">	
								<c:out value="${fn:substringBefore(dept.name, '-')}" escapeXml="false" />
								<input name="selectId" type="radio" value="${dept.id}" onclick="return setId(value);"/>	
								<c:out value="${fn:substringAfter(dept.name, '-')}" escapeXml="false" />		<br />
							</c:forEach>								
						
					
					<input type="hidden" name="control_type" value=""/>	
				
				
					
						
							<h4>Actions</h4>
						
					
					
					
						
							Add subdepartment &nbsp;
						
						
							<input type="text" name="addSub_text" />&nbsp;
						
					
						
							<button type="submit" name="Add" value="Add" onclick="return setControlType('Add');">
			                  Add
							</button>
							<br />
						
					
					
					
					
					
						Delete department &nbsp;
						
							<button type="submit" name="Delete" value="Delete" onclick="return setControlType('Delete');">
								Delete
							</button> <br />
						
					
					
					
						Rename department &nbsp;
						<input type="text" name="rename_text" />&nbsp;
						
							<button type="submit" name="Rename" value="Rename" onclick="return setControlType('Rename');">
							Rename
							</button> 
						
									
				</form>
			
			
			
			<form method="post" action = "employeelist.do">
				<input type="hidden" name="id_type" value=""/>
				
					 Show all employees in department&nbsp;
					
						<button type="submit" name="Show" value="Show" onclick="return setControlType('Show');">
						Show
						</button> <br />
					
				
			</form>
		
			
			<form method="post" action="newdepartment.do">
				
					Create new department &nbsp;
					<input type="text" name="name" />
					<input type="submit" value="Create" /> 
				
			</form>

		</c:when>
		<c:otherwise>
			Incorrect data
		</c:otherwise>
	</c:choose>
	
	</body>
</html>